package testing;

import hypeerweb.node.Contents;
import hypeerweb.node.Node;
import hypeerweb.visitor.Parameters;
import hypeerweb.visitor.SendVisitor;

import java.util.Map.Entry;

public class SendTest extends SendVisitor {
	public String JUMP = "JUMP";
	public String INTER = "ITERMEDIATE";

	public SendTest() {
	}

	/**
	 * Operation performed on target node. copies parameters to contents of
	 * target node
	 * 
	 * @param node
	 *            the target node
	 * @param parameters
	 *            will be copied into contents of node
	 * @pre node is not the NULL_NODE
	 * @post node.contents contains all of the keys and values in parameters
	 */
	protected void targetOperation(Node node, Parameters parameters) {
		Contents contents = node.getContents();
		if (contents.get(JUMP) == null) {
			contents.set(JUMP, 0);
		}
		contents.set("SEND", "FINAL");

		// contents.set(JUMP, jumps++);
	}

	// this might not do anything, simply a method we should call while
	// traversing
	/**
	 * @param node
	 * @param parameters
	 */
	protected void intermediateOperation(Node node, Parameters parameters) {
		if (parameters.get(JUMP) == null) {
			parameters.set(JUMP, 0);
		} else {
			Integer i = ((Integer) parameters.get(JUMP));
			i++;
			parameters.set(JUMP, i);
		}
		
		node.getContents().set(INTER, INTER);
	}
}
